<%--
  Created by IntelliJ IDEA.
  User: 轩宇
  Date: 2024/6/24
  Time: 18:15
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>消费记录详情</title>
    <!-- 采用绝对路径导入css文件 -->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/style.css" />
    <!-- 采用绝对路径导入jquery文件 -->
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.7.2.js"></script>
    <script type="text/javascript">
        $(function () {
            //提示用户添加失败，删除失败，修改失败
            if(!${ empty requestScope.msg }){
                alert("${requestScope.msg}");
            }
            //验证非空，并提交查询请求
            $("#submit").click(function () {
                //验证输入框是否为空
                var keyword = $("#keyword").val();
                if(keyword ==""){
                    alert("请输入关键字");
                    return false;
                }else {
                    //javascript语言提供了一个location地址栏对象
                    //它有一个属性href,可以获取浏览器中地址栏地址
                    location.href="${pageContext.request.contextPath }/homeCostServlet?action=query&keyword="+keyword+"&currentPage=1";
                }
            });
            //验证输入框非空
            $("#tablesubmit").click(function(){
                //验证输入框是否为空
                var costname = $("#costname").val();
                var money = $("#money").val();
                if(costname == null || costname ==""){
                    alert("消费名称不能为空");
                    $("#costname").focus();
                    return false;
                }
                if(money == null || money ==""){
                    alert("消费金额不能为空");
                    $("#money").focus();
                    return false;
                }
            });

        });
    </script>
</head>
<body>
<div id="header">
    <span class="wel_word">编辑消费记录</span>
    <div>
        <a href="${pageContext.request.contextPath }/homeCostServlet?action=listByPage&currentPage=1&givenSize=${param.givenSize}">返回历史记录</a>
        <input style="margin-left:20px"id="keyword" name="keyword" type="text" placeholder="请输入关键字"value=""/>
        <input id="submit"type="submit" value="查询"/>
    </div>
</div>

<div id="main">
    <form action="${pageContext.request.contextPath }/homeCostServlet" method="get">
        <!-- hidden隐藏域,判断是添加请求还是修改请求：param.id取id的值,id为空是添加；id非空是修改 -->
        <table>
            <tr>
                <td>消费名称：</td><td><input disabled="disabled" id="costname" name="name" type="text" value="${requestScope.homeCost.name}"/></td>
            </tr>
            <tr>
                <td>消费金额：</td><td><input disabled="disabled" id="money" name="money" type="text" value="${requestScope.homeCost.money}"/></td>
            </tr>
            <tr>
                <td>登记日期：</td><td><input disabled="disabled" name="date" type="text" value="${requestScope.homeCost.date}"/></td>
            </tr>
            <tr>
                <td>详情：</td><td><input disabled="disabled" name="detail" type="text" value="${requestScope.homeCost.detail}"/></td>
            </tr>
            <tr>
                <!-- 使用el表达式注意在jsp页面(如本页面第一行)导入相应的包 -->
                <input type="hidden" id="id" name="id" value="${requestScope.homeCost.id}">
                <input type="hidden" id="givenSize" name="givenSize" value="${param.givenSize}">
            </tr>
        </table>
    </form>
</div>
</body>
</html>


